import { inject, type App, type InjectionKey } from 'vue'

export const dynamicDialogService = (app: App) => {
  const appContext = app._context

  return {
    appContext
  }
}

export const useDynamicDialogService = () => {
  try {
    const dynamicDialogService = inject(DynamicDialogServiceKey)

    return dynamicDialogService
  } catch (e) {
    return undefined
  }
}

export type DynamicDialogService = ReturnType<typeof dynamicDialogService>

export const DynamicDialogServiceKey: InjectionKey<DynamicDialogService> =
  Symbol('dynamicDialogService')
